package com.xiaode.controller.admin.selfStudyRoom;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.ext.cors.EnableCORS;
import com.jfinal.kit.Ret;
import com.xiaode.common.anotation.Authority;
import com.xiaode.common.anotation.JSONArrayString;
import com.xiaode.util.apidoc.annotation.Api;
import com.xiaode.util.apidoc.annotation.ApiOper;
import com.xiaode.util.apidoc.annotation.ApiPara;

/**
 * 自习室
 */
@Path("/aSelfStudyRoom")
@Api("自习室")
@EnableCORS
public class SelfStudyRoomController extends Controller {
	
	 @Inject
	 private SelfStudyService service;
	 
	 
	 /**
	  * 获取监控教室列表
	  */
	 @ApiOper("获取监控教室列表")
	 @Authority(description = "监控教室列表", permission = "admin:aSelfStudyRoom:getMonitorClassroomList", permissionParentName = "自习室模块", permissionName = "监控教室管理", type = 1)
	 public void getMonitorClassroomList() throws Exception{
		 Ret ret = service.getMonitorClassroomList();
		 renderJson(ret);
	 }
	 
	 /**
	  * 删除监控教室
	  * 删除后，需要删除对应的摄像头绑定关系，以及教室中的人
	  */
	 @ApiOper("删除监控教室")
	 @Authority(description = "删除监控教室", permission = "admin:aSelfStudyRoom:deleteMonitorClassroom", permissionParentName = "自习室模块", permissionName = "监控教室管理", type = 2)	 
	 public void deleteMonitorClassroom(@NotEmpty @ApiPara(value = "monitorClassroomId", notes = "id")Integer monitorClassroomId) throws Exception{
		 Ret ret = service.deleteMonitorClassroom(monitorClassroomId);
		 renderJson(ret);
	 }
	 
	 /**
	  * 添加监控教室
	  */
	 @ApiOper("添加监控教室")
	 @Authority(description = "添加监控教室", permission = "admin:aSelfStudyRoom:addMonitorClassroom", permissionParentName = "自习室模块", permissionName = "监控教室管理", type = 2)
	 public void addMonitorClassroom(
			 @NotBlank @ApiPara(value = "pictureUrl", notes = "图片")String pictureUrl, 
			 @NotBlank @ApiPara(value = "name", notes = "教室名称")String name, 
			 @NotBlank @JSONArrayString @ApiPara(value = "cameraIds", notes = "摄像头id数组[]")String cameraIds) throws Exception{
		 Ret ret = service.addMonitorClassroom(pictureUrl, name, cameraIds);
		 renderJson(ret);
	 }
	 
	 /**
	  * 获取监控教室配置详情
	  */
	 @ApiOper("获取监控教室配置详情")
	 @Authority(description = "获取监控教室配置详情", permission = "admin:aSelfStudyRoom:getMonitorClassroom", permissionParentName = "自习室模块", permissionName = "监控教室管理", type = 1)
	 public void getMonitorClassroom(@NotEmpty @ApiPara(value = "monitorClassroomId", notes = "id")Integer monitorClassroomId) throws Exception{
		 Ret ret = service.getMonitorClassroom(monitorClassroomId);
		 renderJson(ret);
	 }
	 
	 /**
	  * 修改监控教室
	  */
	 @ApiOper("修改监控教室")
	 @Authority(description = "修改监控教室", permission = "admin:aSelfStudyRoom:updateMonitorClassroom", permissionParentName = "自习室模块", permissionName = "监控教室管理", type = 2)
	 public void updateMonitorClassroom(
			 @NotEmpty @ApiPara(value = "monitorClassroomId", notes = "id")Integer monitorClassroomId,
			 @NotBlank @ApiPara(value = "pictureUrl", notes = "图片")String pictureUrl, 
			 @NotBlank @JSONArrayString @ApiPara(value = "cameraIds", notes = "摄像头id数组[]")String cameraIds) throws Exception{
		 Ret ret = service.updateMonitorClassroom(monitorClassroomId, pictureUrl, cameraIds);
		 renderJson(ret);
	 }
	 
	 /**
	  * 获取教室摄像头监控流
	  */
	 @ApiOper("获取教室摄像头监控流")
	 @Authority(description = "获取教室摄像头监控流", permission = "admin:aSelfStudyRoom:getPreviewURLs", permissionParentName = "自习室模块", permissionName = "摄像头管理", type = 1)	 
	 public void getPreviewURLs(@NotEmpty @ApiPara(value = "monitorClassroomId", notes = "id")Integer monitorClassroomId) throws Exception{
		 Ret ret = service.getPreviewURLs(monitorClassroomId);
		 renderJson(ret);
	 }
	 
	 /**
	  * 获取教室摄像头回放流
	  */
	 @ApiOper("获取教室摄像头回放流")
	 @Authority(description = "获取教室摄像头回放流", permission = "admin:aSelfStudyRoom:getPlaybackURLs", permissionParentName = "自习室模块", permissionName = "摄像头管理", type = 1)	 
	 public void getPlaybackURLs(
			 @NotEmpty @ApiPara(value = "monitorClassroomId", notes = "id")Integer monitorClassroomId,
			 @NotBlank @ApiPara(value = "beginTime", notes = "开始时间")String beginTime, 
			 @NotBlank @ApiPara(value = "endTime", notes = "结束时间")String endTime) throws Exception{
		 Ret ret = service.getPlaybackURLs(monitorClassroomId, beginTime, endTime);
		 renderJson(ret);
	 }
	 
	 /**
	  * 获取某个摄像头回放流
	  */
	 @ApiOper("获取某个摄像头回放流")
	 @Authority(description = "获取某个摄像头回放流", permission = "admin:aSelfStudyRoom:getPlaybackURL", permissionParentName = "自习室模块", permissionName = "摄像头管理", type = 1)
	 public void getPlaybackURL(
			 @NotEmpty @ApiPara(value = "cameraId", notes = "id")Integer cameraId, 
			 @NotBlank @ApiPara(value = "beginTime", notes = "开始时间")String beginTime, 
			 @NotBlank @ApiPara(value = "endTime", notes = "结束时间")String endTime) throws Exception{
		 Ret ret = service.getPlaybackURL(cameraId, beginTime, endTime);
		 renderJson(ret);
	 }
	 
	 /**
	  * 获取没有关联教室的摄像头，创建监控教室时使用
	  */
	 @ApiOper("获取没有关联教室的摄像头")
	 @Authority(description = "获取没有关联教室的摄像头", permission = "admin:aSelfStudyRoom:getNoBindingCamera", permissionParentName = "自习室模块", permissionName = "摄像头管理", type = 1)
	 public void getNoBindingCamera() throws Exception{
		 Ret ret = service.getNoBindingCamera();
		 renderJson(ret);
	 }
	 
	 /**
	  * 删除摄像头
	  */
	 @ApiOper("删除摄像头")
	 @Authority(description = "删除摄像头", permission = "admin:aSelfStudyRoom:deleteCamera", permissionParentName = "自习室模块", permissionName = "摄像头管理", type = 2)
	 public void deleteCamera(@NotEmpty @ApiPara(value = "cameraId", notes = "摄像头id")Integer cameraId) throws Exception{
		 Ret ret = service.deleteCamera(cameraId);
		 renderJson(ret);
	 }
	 
	 
	 
}
